package com.ulife.permission.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ulife.permission.dao.DepartmentDao;
import com.ulife.permission.dao.dataobject.DepartmentDO;

public class DepartmentDaoImpl extends SqlMapClientDaoSupport implements DepartmentDao {

	public DepartmentDO getDepartmentById(long departmentId) throws SQLException {
		return (DepartmentDO)getSqlMapClient().queryForObject("Department.getDepartmentById",departmentId);
	}

	public int addDepartment(DepartmentDO department) throws SQLException {
		return getSqlMapClient().update("Department.insertDepartment",department);
	}

	@SuppressWarnings("unchecked")
	public List<DepartmentDO> getAllDepartment() throws SQLException {
		return getSqlMapClient().queryForList("Department.selectAllDepartments");
	}

	public int delDepartment(long departmentId) throws SQLException {
		return getSqlMapClient().update("Department.delDepartment", departmentId);
	}

	public int updateDepartment(DepartmentDO department) throws SQLException {
		return getSqlMapClient().update("Department.updateDepartment", department);
	}

	@SuppressWarnings("unchecked")
	public List<DepartmentDO> getAllAvailableDepartment() throws SQLException {
		return getSqlMapClient().queryForList("Department.getAllAvailableDepartment");
	}

}
